<template>
  <div>
    user里面的num
    <br>
    <!-- {{ $store.state.user.num }} -->
    <button @click="addNum">user模块中 的num +</button>
    {{userNum}}
    <hr>
    order里面的num
    <br>
    {{orderNum}}
    <!-- {{ $store.state.order.num }} -->
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  methods: {
    addNum () {
      // this.$store.commit('user/ADD_NUM', 10)
      // this['user/ADD_NUM'](10)
      this.ADD_NUM(10)
    },
    // ...mapMutations(['user/ADD_NUM'])
    ...mapMutations('user', ['ADD_NUM'])
  },
  computed: {
    ...mapState({
      orderNum: state => state.order.num,
      userNum: state => state.user.num
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
